﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace Future.Common
{
    public class Msg
    {
        /// <summary>
        /// [CN]系统标题
        /// </summary>
        private const string assemblyTitle = "FutureCRM";

        /// <summary>
        /// 询问
        /// </summary>
        /// <param name="msg">询问消息语句</param>
        /// <returns></returns>
        public static bool AskQuestion(string msg)
        {
            DialogResult r;
            r = XtraMessageBox.Show(msg, assemblyTitle + "[确定消息]", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
            return r == DialogResult.Yes;
        }

        /// <summary>
        /// 错误警告
        /// </summary>
        /// <param name="e"></param>
        public static void ShowException(Exception e)
        {
            string s = e.Message;
            string innerMsg = string.Empty;

            if (e.InnerException != null)
            {
                innerMsg = e.InnerException.Message;
                s += "\n" + innerMsg;
            }
            Warning(s);

        }

        /// <summary>
        /// 警告
        /// </summary>
        /// <param name="msg"></param>
        public static void Warning(string msg)
        {
            XtraMessageBox.Show(msg, assemblyTitle + "[警告信息]", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
        }

        /// <summary>
        /// 错误提醒
        /// </summary>
        /// <param name="msg"></param>
        public static void ShowError(string msg)
        {
            XtraMessageBox.Show(msg, assemblyTitle + "[错误提醒]", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
        }

        /// <summary>
        /// 消息提示
        /// </summary>
        /// <param name="msg"></param>
        public static void ShowInformation(string msg)
        {
            XtraMessageBox.Show(msg, assemblyTitle + "[信息提示]", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
        }
    }
}
